Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

machine.channel Fix hanging on read_until_prompt. #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacekk-nr
Copy link

On some devices, logs may be printed just after the prompt. In such case prompt lands in the middle of a buffer, not at the end. This change is to avoid infinite hanging in such cases.

On some devices, logs may be printed just after the prompt. In such case
prompt lands in the middle of a buffer, not at the end. This
change is to avoid infinite hanging in such cases.

Signed-off-by: jacekk <[email protected]>
@Rahix
Copy link
Owner

Rahix commented Jun 23, 2024

Hi,

tbot intentionally only accepts a prompt at the very end of the input stream. If there are messages on the console that get printed in-between synchronous command execution, tbot cannot work reliably at all. The solution must always be to avoid the clutter. Any other way, and you will see random testcase failures that can't be controlled.

Maybe you can share a few more details about the situation where you are facing this problem? Usually, there are workaround to console clutter from the various sources.

@jacekk-nr
Copy link
Author

Hi,

On one hand, I understand your chain of thoughts. On the other, to have robust automation, it's better to be prepared for the worst case.

Practical example is a device that experiences link flapping during the test, so it logs link up/link down events. Sometimes, such event lands at the end of a buffer, just after the prompt. Of course, with some effort, these events can be silenced, but then we lose a bit of observability.

Please take a look a few lines under the proposed patch. In case of BoundedPattern prompt, tbot uses search, instead of endswith equivalant. That is actually what convinced me that endswith->find may be a desired solution for tbot community.

                elif isinstance(self.prompt, BoundedPattern):
                    match = self.prompt.pattern.**search**(buf)

BR,
Jacek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants